module.exports = function(app) {
  var express = require('express');
  var rolesRouter = express.Router();

  rolesRouter.get('/', function(req, res) {
    res.send({
      "_links": {
        "self": {
          "href": "http://localhost/api/v1/roles{?page,size,sort,projection}",
          "templated": true
        },
        "search": {
          "href": "http://localhost/api/v1/roles/search"
        }
      },
      "_embedded": {
        "roles": [{
          "name": "ROLE_USER",
          "id": 1,
          "_links": {
            "self": {
              "href": "http://localhost/api/v1/roles/1{?projection}",
              "templated": true
            }
          }
        }, {
          "name": "ROLE_WORKER",
          "id": 2,
          "_links": {
            "self": {
              "href": "http://localhost/api/v1/roles/2{?projection}",
              "templated": true
            }
          }
        }, {
          "name": "ROLE_APP_DATA_CHANGE_FIX_RATE",
          "id": 3,
          "_links": {
            "self": {
              "href": "http://localhost/api/v1/roles/3{?projection}",
              "templated": true
            }
          }
        }, {
          "name": "ROLE_USER_MANAGER",
          "id": 4,
          "_links": {
            "self": {
              "href": "http://localhost/api/v1/roles/4{?projection}",
              "templated": true
            }
          }
        }, {
          "name": "ROLE_SCANAPI_CLIENT",
          "id": 131074,
          "_links": {
            "self": {
              "href": "http://localhost/api/v1/roles/131074{?projection}",
              "templated": true
            }
          }
        }]
      },
      "page": {
        "size": 20,
        "totalElements": 5,
        "totalPages": 1,
        "number": 0
      }
    });
  });

  rolesRouter.post('/', function(req, res) {
    res.status(201).json(

      {
        "id": 262144,
        "createdAt": new Date(),
        "archived": false,
        "keyId": "54E2D474536248D3A447F5E82DBB8392",
        "keySecret": "76bbb7e12319416599dbbe2d52481410",
        "useTimes": 0,
        "_embedded": {
          "creator": {
            "id": 3,
            "displayName": "1b6e5cf7a5f6434a934f9a040b65238a@openscanner.cc",
            "level": 1,
            "avatar": "",
            "gender": "FEMAIL",
            "email": "1b6e5cf7a5f6434a934f9a040b65238a@openscanner.cc",
            "ucOpenId": "1b6e5cf7a5f6434a934f9a040b65238a",
            "roles": [{
              "name": "ROLE_USER"
            }, {
              "name": "ROLE_WORKER"
            }],
            "createdAt": "2015-08-27T02:39:31.761+0000",
            "lastScheduleExec": null,
            "_links": {
              "self": {
                "href": "http://localhost/api/v1/roles/3{?projection}",
                "templated": true
              }
            }
          }
        },
        "_links": {
          "self": {
            "href": "http://localhost/api/v1/roles/262144{?projection}",
            "templated": true
          },
          "creator": {
            "href": "http://localhost/api/v1/roles/262144/creator"
          }
        }
      }
    );
  });

  rolesRouter.get('/:id', function(req, res) {
    res.send({
      "id": 163840,
      "createdAt": "2015-08-18T08:16:41.816+0000",
      "archived": false,
      "keyId": "B075D48BB6EF4B9D90A5852967A145DD",
      "keySecret": "b3256df680ea4e90b4ef342f99681e73",
      "useTimes": 0,
      "_embedded": {
        "creator": {
          "id": 3,
          "displayName": "1b6e5cf7a5f6434a934f9a040b65238a@openscanner.cc",
          "level": 1,
          "roles": [{
            "name": "ROLE_USER"
          }],
          "createdAt": "2015-08-18T01:00:06.723+0000",
          "lastScheduleExec": null,
          "gender": "FEMAIL",
          "avatar": "",
          "email": "1b6e5cf7a5f6434a934f9a040b65238a@openscanner.cc",
          "ucOpenId": "1b6e5cf7a5f6434a934f9a040b65238a",
          "_links": {
            "self": {
              "href": "http://localhost/api/v1/roles/3{?projection}",
              "templated": true
            }
          }
        }
      },
      "_links": {
        "self": {
          "href": "http://localhost/api/v1/roles/163840{?projection}",
          "templated": true
        },
        "creator": {
          "href": "http://localhost/api/v1/roles/163840/creator"
        }
      }
    });
  });

  rolesRouter.put('/:id', function(req, res) {
    res.send({
      'roles': {
        id: req.params.id
      }
    });
  });

  rolesRouter.delete('/:id', function(req, res) {
    res.status(204).end();
  });

  app.use('/api/v1/roles', rolesRouter);
};
